<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="common/header.jsp" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>日志列表</title>
</head>
<style>



</style>

<body style="padding:1rem;">

<table class="layui-table">
	<colgroup>
		<col width="150">
		<col width="200">
		<col>
	</colgroup>
	<thead>
	<tr>
		<th>开始版本</th>
		<th>结束版本</th>
		<th>补丁时间</th>
	</tr> 
	</thead>
	<tbody id="logs"></tbody>
</table>

</body>
</html>
<script>

var projectId = '${plog.project.id}';
$.ajax({
	url: '${webRoot}/log/logs?project.id='+projectId,
	success: function(data){
		var html = '';
		$.each(data, function(i, item){
			html += '<tr onclick="toLogDetail('+item.logPath+')">';
			html += '<td>'+item.versionStart+'</td>';
			html += '<td>'+item.versionEnd+'</td>';
			var d = new Date();
			d.setTime(item.createTime);
			html += '<td>'+d.format('yyyy-MM-dd h:m:s')+'</td>';
			html += '</tr>';
		});
		$('#logs').html(html);
	}
});

function toLogDetail(logPath){
	layer.open({
		title: '补丁详情',
		type: 2,
		area: ['50rem', '40rem'],
		fixed: false, //不固定
		maxmin: true,
		content: '${webRoot}/log/ld?logPath='+logPath,
		btn: ['关闭']
	});
}

Date.prototype.format = function(format) {
    var date = {
           "M+": this.getMonth() + 1,
           "d+": this.getDate(),
           "h+": this.getHours(),
           "m+": this.getMinutes(),
           "s+": this.getSeconds(),
           "q+": Math.floor((this.getMonth() + 3) / 3),
           "S+": this.getMilliseconds()
    };
    if (/(y+)/i.test(format)) {
           format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
    }
    for (var k in date) {
           if (new RegExp("(" + k + ")").test(format)) {
                  format = format.replace(RegExp.$1, RegExp.$1.length == 1
                         ? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
           }
    }
    return format;
}

</script>